package com.web.dao;

import com.web.entity.TechInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface TechInfoMapper {
    @Delete({
        "delete from APP_TECH_INFO",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into APP_TECH_INFO (user_id, logo, ",
        "city, business, ",
        "introduction, tech_photos, ",
        "device_photos, create_time, ",
        "modify_time)",
        "values (#{userId,jdbcType=VARCHAR}, #{logo,jdbcType=VARCHAR}, ",
        "#{city,jdbcType=VARCHAR}, #{business,jdbcType=VARCHAR}, ",
        "#{introduction,jdbcType=VARCHAR}, #{techPhotos,jdbcType=VARCHAR}, ",
        "#{devicePhotos,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(TechInfo record);

    int insertSelective(TechInfo record);

    @Select({
        "select",
        "id, user_id, logo, city, business, introduction, tech_photos, device_photos, ",
        "create_time, modify_time",
        "from APP_TECH_INFO",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    TechInfo selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(TechInfo record);

    @Update({
        "update APP_TECH_INFO",
        "set user_id = #{userId,jdbcType=VARCHAR},",
          "logo = #{logo,jdbcType=VARCHAR},",
          "city = #{city,jdbcType=VARCHAR},",
          "business = #{business,jdbcType=VARCHAR},",
          "introduction = #{introduction,jdbcType=VARCHAR},",
          "tech_photos = #{techPhotos,jdbcType=VARCHAR},",
          "device_photos = #{devicePhotos,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(TechInfo record);

    TechInfo findTechInfo(@Param("key") String key,@Param("value") String value);
}